<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>testD3-2.html</title>
    <script type="text/javascript" src="d3.js"></script>
</head>
<body>
<p>d表示当前数据值</p>
<script type="text/javascript">

    var dataset = [ 5, 10, 15, 20, 25 ];

    d3.select("body").selectAll("p")
        .data(dataset)
        .enter()
        .append("p")
        .text(function(d) {
            return "I can count up to " + d;
        })
        .style("color", function(d) {
            if (d > 15) { //大于15的数字显示为红色
                return "red";
            } else {
                return "black";
            }
        });

</script>
</body>
</html>